<!--
 * @Author: 曹捷
 * @Date: 2020-11-14 00:51:36
 * @LastEditors: 曹捷
 * @LastEditTime: 2020-12-01 15:59:43
 * @Description: fileContent
-->
<template>
  <uni-popup :ref="createKey" type="dialog">
    <uni-popup-dialog type="success" :cancelName="options.cancelName" :confirmName="options.confirmName"
      :title="options.title" :content="options.content" :before-close="true" @confirm="confirm" @close="dialogClose">
    </uni-popup-dialog>
  </uni-popup>
</template>

<script>
import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog'
export default {
  components: { uniPopupDialog },
  data () {
    return {
      options: {
        type: 'success',
        title: '成功',
        cancelName: '取消',
        confirmName: '确定',
        content: '',
      },
      createKey: ''
    }
  },
  methods: {
    open (option) {
      Object.assign(this.options, option)
      this.$refs[this.createKey].open()
    },
    dialogClose (done) {
      if (this.options.close) {
        return this.options.close(done)
      } else {
        done()
      }

    },
    confirm (done) {
      if (this.options.confirm) {
        this.options.confirm(done)
      } else {
        done()
      }
    }
  },
  created () {
    this.createKey = Math.random() * 1000;
  },
}
</script>

<style>
</style>